<template>
  <div>
    <van-search
  
      v-model="keyword"
      shape="round"
      background="white"
      placeholder="请输入课程名搜索"
      @input="onSearch"
    />
    
      <van-cell v-for="(item,index) in filList" :key="index" style="marginBottom:8px" 
      @click="onClick(index)" :title="item.name" :label="item.time">
        <template #right-icon> </template>
      </van-cell>
  
  
  </div>
</template>


<script>
export default {
  data() {
    return {
      keyword:"",
      classroom: "默认班级",
      filList:[],
      list: [
        {
          name: "第一章作业",
          time: "2022.3.1",
        },
        {
          name: "第二章作业",
          time: "2022.3.2",
        },
        {
          name: "第三章作业",
          time: "2022.3.3",
        },
      ],
    };
  },
  watch :{
    keyword:{
      immediate:true,
      handler(val){
        this.filList = this.list.filter((item) => {
          return item.name.indexOf(val) != -1
        })
      }
    }
  },
  methods:{
  
    onSearch(){

    },
    onClick(i){
      console.log(i);
    }
  }

};
</script>

<style scoped>
</style>